<?php 
//引进配置信息
include 'include/init.php';
//引入数据库配置信息
include 'include/mysql.config.php';
//引入公共函数
include 'include/common.fun.php';
include 'data/common_data.php';


if(!isset($_COOKIE['user_login']) || $_COOKIE['user_login']!=1){
	alert('请登录','user_login.php');
}

$id = $_COOKIE['user_id'];
$sql="SELECT * from wd_user where user_id=$id";
$info=$db->getOne($sql);

$sql="SELECT * from wd_district where parentid=1";
$parentid=$db->getAll($sql);

if ($_POST) {
	$username=$_POST['name'];
	$sex=$_POST['gender'];
	$birthday=$_POST['birthday'];
	$tel=$_POST['tel'];
	$email=$_POST['email'];
	$user_qq=$_POST['qq'];
	$province=$_POST['province'];
	$city=$_POST['city'];
	$town=$_POST['town'];

	$sql="SELECT categoryname from wd_district where id='$province'";
	$province1=$db->getOne($sql);
	$sql="SELECT categoryname from wd_district where id='$city'";
	$city1=$db->getOne($sql);
	$sql="SELECT categoryname from wd_district where id='$town'";
	$town1=$db->getOne($sql);
	
	$date=array(
		'user_first_name'=>$username,
		'user_sex'=>$sex,
		'user_birthday'=>$birthday,
		'user_tel'=>$tel,
		'user_email'=>$email,
		'user_qq'=>$user_qq,
		'user_address'=>$province1['categoryname'].$city1['categoryname'].$town1['categoryname']
		);
	$where='user_id='.$id;
	$res=$db->update('wd_user',$date,$where);
	if ($res) {
		alert('更新成功','user_center.php');
	}else{
		alert('更新失败');
	}
}
//加载视图页面
include 'view/user_setting.php';




 ?>